home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectInput / DIConfig / flexscrollbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  2.7 KB  |  106 lines

  1. //-----------------------------------------------------------------------------
  2. // File: flexscrollbar.h
  3. //
  4. // Desc: Implements CFlexScrollBar (derived from CFlexWnd), a scroll bar
  5. //       control similar to a Windows scroll bar.
  6. //
  7. // Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
  8. //-----------------------------------------------------------------------------
  9.  
  10. #ifndef __FLEXSCROLLBAR_H__
  11. #define __FLEXSCROLLBAR_H__
  12.  
  13.  
  14. #include "flexwnd.h"
  15.  
  16.  
  17. #define FSBF_HORZ    0
  18. #define FSBF_VERT    1
  19.  
  20. struct FLEXSCROLLBARCREATESTRUCT {
  21.     DWORD dwSize;
  22.     DWORD dwFlags;
  23.     int min, max, page, pos;
  24.     HWND hWndParent;
  25.     HWND hWndNotify;
  26.     RECT rect;
  27.     BOOL bVisible;
  28. };
  29.  
  30. class CFlexScrollBar : public CFlexWnd
  31. {
  32. public:
  33.     CFlexScrollBar();
  34.     ~CFlexScrollBar();
  35.  
  36.     BOOL Create(FLEXSCROLLBARCREATESTRUCT *);
  37.  
  38.     void SetColors(COLORREF bk, COLORREF fill, COLORREF line);
  39.  
  40.     void SetValues(int, int, int, int);
  41.     void SetValues(int min, int max, int page) {SetRange(min, max, page);}
  42.     void SetValues(int min, int max) {SetRange(min, max);}
  43.  
  44.     void SetRange(int min, int max, int page) {SetValues(min, max, page, GetPos());}
  45.     void SetRange(int min, int max) {SetRange(min, max, GetPage());}
  46.  
  47.     void SetMin(int v) {SetValues(v, GetMax(), GetPage(), GetPos());}
  48.     void SetMax(int v) {SetValues(GetMin(), v, GetPage(), GetPos());}
  49.     void SetPage(int v) {SetValues(GetMin(), GetMax(), v, GetPos());}
  50.     void SetPos(int v) {SetValues(GetMin(), GetMax(), GetPage(), v);}
  51.  
  52.     int GetMin() {return m_nMin;}
  53.     int GetMax() {return m_nMax;}
  54.     int GetPage() {return m_nPage;}
  55.     int GetPos() {return m_nPos;}
  56.  
  57.     int GetThumbPos() {return m_bDragging ? m_nThumbPos : -1;}
  58.  
  59.     void AdjustPos(int adj, BOOL bForceCalc = FALSE);
  60.  
  61. protected:
  62.     virtual void OnPaint(HDC hDC);
  63.     virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  64.  
  65. private:
  66.     int m_nMin, m_nMax, m_nPage, m_nPos;
  67.     BOOL m_bVert;
  68.     HWND m_hWndNotify;
  69.  
  70.     COLORREF m_rgbBk, m_rgbFill, m_rgbLine;
  71.  
  72.     // ui rects...  calced by Calc
  73.     RECT m_rectLineUp;
  74.     RECT m_rectPageUp;
  75.     RECT m_rectTrack;
  76.     RECT m_rectThumb;
  77.     RECT m_rectPageDown;
  78.     RECT m_rectLineDown;
  79.  
  80.     BOOL Calc();
  81.     BOOL FailCalc(BOOL);
  82.     BOOL m_bValid;  // true only when we have been created and hav valid values
  83.                     // and calc has been called and returned successfully.
  84.  
  85.     void InternalPaint(HDC hDC);
  86.     
  87.     POINT m_point, m_startpoint;
  88.     int m_nThumbPos, m_nPreDragPos;
  89.     int m_code;
  90.     int m_startcode;
  91.     BOOL m_bCapture;
  92.     BOOL m_bDragging;
  93.  
  94.     int HitTest(POINT point);
  95.     void Notify(int code);
  96.  
  97.     int GetLineAdjust();
  98.     int GetPageAdjust();
  99. };
  100.  
  101.  
  102. CFlexScrollBar *CreateFlexScrollBar(FLEXSCROLLBARCREATESTRUCT *pcs);
  103.  
  104.  
  105. #endif //__FLEXSCROLLBAR_H__
  106.